package aiku.numericalcontroloa.Base.Utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 自动导入基类中的时间
 * @ClassName com.mysterymall.Common.Config
 * @Description
 * @Author HuangWX
 * @Time 2023/11/03  01:14
 */
@Component
@Slf4j
public class MyBatisPlusComp implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime",  new Date(), metaObject);
        this.setFieldValByName("updateTime",  new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",  new Date(), metaObject);
    }
}
